package com.fintech.third.utils;

import java.util.Properties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.fintech.third.model.ThirdProperties;
import com.marvels.common.utils.MarvelsLogUtil;


@Component
public class ThirdPropertiesInitUtil {
	private static Long last_user_properties_time = null;
	private static Long lastInitPropertiesTime=null;
	private static long read_hz = 1 * 60 * 1000;
	private static ThirdProperties thirdProperties = new ThirdProperties();
	private static Properties readProperties=new Properties();
	private static Properties extProperties=new Properties();

	/**
	 * 第三方接口初始化
	 * 
	 * @return
	 */
//	public static Properties getProperties(){
//		long current_time=System.currentTimeMillis();
//		if(last_user_properties_time==null || (last_user_properties_time!=null&&current_time-last_user_properties_time>read_hz)){//超过5分钟重新查询一次
//			MarvelsLogUtil.getInstance().info("====超过5分钟重新初始化第三方配置");
//			 readProperties = SystemUtil.readProperties("deploy.properties");
//			last_user_properties_time=System.currentTimeMillis();
//		}
//		if(readProperties==null){
//			return null;
//		}
//		return readProperties;
//	}
	/**
	 * lgb
	 * deploy.properties配置文件
	 * @param configPath
	 * @return
	 */
	public static Properties lgbinitProperties(String configPath){
		long current_time=System.currentTimeMillis();
		MarvelsLogUtil.getInstance().info("====超过5分钟重新初始化第三方配置 ==lastInitPropertiesTime="+lastInitPropertiesTime);
		if(lastInitPropertiesTime==null || (lastInitPropertiesTime!=null&&current_time-lastInitPropertiesTime>read_hz)){//超过5分钟重新查询一次
			readProperties=ThirdSystemUtil.readProperties(configPath);
			lastInitPropertiesTime=System.currentTimeMillis();
		}
		if(null == readProperties){
			return new Properties();
		}
		return readProperties;
	}
	
	/**
	 * 除了deploy.properties以外的properties初始化
	 * @param configPath
	 * @return
	 */
	public static Properties initProperties(String configPath){
		long current_time=System.currentTimeMillis();
		MarvelsLogUtil.getInstance().info("====超过5分钟重新初始化第三方配置 ==lastInitPropertiesTime="+lastInitPropertiesTime);
		if(lastInitPropertiesTime==null || (lastInitPropertiesTime!=null&&current_time-lastInitPropertiesTime>read_hz)){//超过5分钟重新查询一次
			extProperties=ThirdSystemUtil.readProperties(configPath);
			lastInitPropertiesTime=System.currentTimeMillis();
		}
		if(null == extProperties){
			return new Properties();
		}
		return extProperties;
	}
	
	
	
	
	
	/**
	 * deploy.properties初始化
	 * @return
	 */
	public static ThirdProperties getThirdProperties(){
		long current_time=System.currentTimeMillis();
		MarvelsLogUtil.getInstance().info("====超过5分钟重新初始化第三方配置 ==lastInitPropertiesTime="+lastInitPropertiesTime);
		if(last_user_properties_time==null || (last_user_properties_time!=null&&current_time-last_user_properties_time>read_hz)){//超过5分钟重新查询一次
			initThirdProperties(ThirdSystemUtil.readProperties("deploy.properties"));
			last_user_properties_time=System.currentTimeMillis();
		}
		if(thirdProperties==null){
			return new ThirdProperties();
		}
		return thirdProperties;
	}
	
	public static ThirdProperties initThirdProperties(Properties properties) {
		thirdProperties.setTencent_send_url(properties.getProperty("tencent_send_url").toString().trim());
		thirdProperties.setTencent_sdk_appid(properties.getProperty("tencent_sdk_appid").toString().trim());
		thirdProperties.setTencent_sms_appkey(properties.getProperty("tencent_sms_appkey").toString().trim());
		thirdProperties.setMiddle_send_url(properties.getProperty("middle_send_url").toString().trim());
		thirdProperties.setMiddle_sdk_appid(properties.getProperty("middle_sdk_appid").toString().trim());
		thirdProperties.setMiddle_sms_appkey(properties.getProperty("middle_sms_appkey").toString().trim());
		thirdProperties.setBf_member_id(properties.getProperty("bf_member_id").toString().trim());
		thirdProperties.setBf_priKeyPass(properties.getProperty("bf_priKeyPass").toString().trim());
		thirdProperties.setBf_terminal_id(properties.getProperty("bf_terminal_id").toString().trim());
		thirdProperties.setBf_tradeStatusUrl(properties.getProperty("bf_tradeStatusUrl").toString().trim());
		thirdProperties.setBf_withHoldUrl(properties.getProperty("bf_withHoldUrl").toString().trim());
		thirdProperties.setFast_pay_version(properties.getProperty("fast_pay_version").toString().trim());
		thirdProperties.setFast_pfx_pwd(properties.getProperty("fast_pfx_pwd").toString().trim());
		thirdProperties.setSt_api_id(properties.getProperty("st_api_id").toString().trim());
		thirdProperties.setSt_api_secret(properties.getProperty("st_api_secret").toString().trim());
		thirdProperties.setSt_idVerificationUrl(properties.getProperty("st_idVerificationUrl").toString().trim());
		thirdProperties.setSt_faceAligmentUrl(properties.getProperty("st_faceAligmentUrl").toString().trim());
		thirdProperties.setYt_comparisonUrl(properties.getProperty("yt_comparisonUrl").toString().trim());
		thirdProperties.setYt_idCardVerifyUrl(properties.getProperty("yt_idCardVerifyUrl").toString().trim());
		thirdProperties.setShzx_batchCreditWebServiceURI(
				properties.getProperty("shzx_batchCreditWebServiceURI").toString().trim());
		thirdProperties.setShzx_msgSubmitWebServiceURI(
				properties.getProperty("shzx_msgSubmitWebServiceURI").toString().trim());
		thirdProperties.setShzx_orgcode(properties.getProperty("shzx_orgcode").toString().trim());
		thirdProperties.setShzx_password(properties.getProperty("shzx_password").toString().trim());
		thirdProperties.setShzx_queryCreditWebServiceURI(
				properties.getProperty("shzx_queryCreditWebServiceURI").toString().trim());
		thirdProperties.setShzx_ssecret(properties.getProperty("shzx_ssecret").toString().trim());
		thirdProperties.setShzx_step1URI(properties.getProperty("shzx_step1URI").toString().trim());
		thirdProperties.setShzx_step2URI(properties.getProperty("shzx_step2URI").toString().trim());
		thirdProperties.setShzx_username(properties.getProperty("shzx_username").toString().trim());
		thirdProperties.setShzx_zippassword(properties.getProperty("shzx_zippassword").toString().trim());
		thirdProperties.setBr_apiCode(properties.getProperty("br_apiCode").toString().trim());
		thirdProperties.setBr_loginRequestUrl(properties.getProperty("br_loginRequestUrl").toString().trim());
		thirdProperties.setBr_merchantName(properties.getProperty("br_merchantName").toString().trim());
		thirdProperties.setBr_merchantPwd(properties.getProperty("br_merchantPwd").toString().trim());
		thirdProperties.setBr_packetRequestUrl(properties.getProperty("br_packetRequestUrl").toString().trim());
		thirdProperties.setBr_reportRequestUrl(properties.getProperty("br_reportRequestUrl").toString().trim());
		thirdProperties
				.setBr_oneCreditCard_apiCode(properties.getProperty("br_oneCreditCard_apiCode").toString().trim());
		thirdProperties.setBr_oneCreditCard_loginRequestUrl(
				properties.getProperty("br_oneCreditCard_loginRequestUrl").toString().trim());
		thirdProperties.setBr_oneCreditCard_merchantName(
				properties.getProperty("br_oneCreditCard_merchantName").toString().trim());
		thirdProperties.setBr_oneCreditCard_merchantPwd(
				properties.getProperty("br_oneCreditCard_merchantPwd").toString().trim());
		thirdProperties.setBr_oneCreditCard_packetRequestUrl(
				properties.get("br_oneCreditCard_packetRequestUrl").toString().trim());
		thirdProperties.setBf_cer_path(properties.getProperty("bf_cer_path").toString().trim());
		thirdProperties.setBf_pfx_path(properties.getProperty("bf_pfx_path").toString().trim());
		thirdProperties.setFast_pfx_path(properties.getProperty("fast_pfx_path").toString().trim());
		thirdProperties.setMx_api_key(properties.getProperty("mx_api_key").toString().trim());
		thirdProperties.setMx_baseUrl(properties.getProperty("mx_baseUrl").toString().trim());
		thirdProperties.setMx_token(properties.getProperty("mx_token").toString().trim());
		thirdProperties.setWt_sms_sname(properties.getProperty("wt_sms_sname").toString().trim());
		thirdProperties.setWt_sms_spwd(properties.getProperty("wt_sms_spwd").toString().trim());
		thirdProperties.setWt_sms_url(properties.getProperty("wt_sms_url").toString().trim());
		thirdProperties.setImage_path(properties.getProperty("image_path"));
		thirdProperties.setPolling_time(Long.parseLong(properties.getProperty("polling_time").toString().trim()));
		thirdProperties.setYt_access_id(properties.getProperty("yt_access_id").toString().trim());
		thirdProperties.setYt_ocr_Universal(properties.getProperty("yt_ocr_Universal").toString().trim());
		thirdProperties.setYt_public_key(properties.getProperty("yt_public_key").toString().trim());
		thirdProperties.setYt_signature_key(properties.getProperty("yt_signature_key").toString().trim());
		thirdProperties.setSt_bankCard_distinguishUrl(properties.getProperty("st_bankCard_distinguishUrl").toString().trim());
		thirdProperties.setBf_pay_Url(properties.getProperty("bf_pay_Url").toString().trim());
		thirdProperties.setBf_pay_checkUrl(properties.getProperty("bf_pay_checkUrl").toString().trim());
		thirdProperties.setFast_replace_payment_product_no(properties.getProperty("fast_replace_payment_product_no").toString().trim());
		thirdProperties.setFast_port(properties.getProperty("fast_port").toString().trim());
		thirdProperties.setIs_brusage_details_dg(properties.getProperty("is_brusage_details_dg").toString().trim());
		thirdProperties.setIs_not_sms_timing_send(properties.getProperty("is_not_sms_timing_send").toString().trim());
		thirdProperties.setIs_mx_new_programme_user(properties.getProperty("is_mx_new_programme_user").toString().trim());
		thirdProperties.setSpeed_shield_account(properties.getProperty("speed_shield_account").toString().trim());
		thirdProperties.setSpeed_shield_pswd(properties.getProperty("speed_shield_pswd").toString().trim());
		thirdProperties.setSpeed_shield_url(properties.getProperty("speed_shield_url").toString().trim());
		thirdProperties.setIs_sms_send(properties.getProperty("is_sms_send").toString().trim());
		thirdProperties.setFast_reconciliation_need_product_no(properties.getProperty("fast_reconciliation_need_product_no").trim().toString());
		thirdProperties.setSpeed_shield_account_collection(properties.getProperty("speed_shield_account_collection").trim().toString());
		thirdProperties.setSpeed_shield_pswd_collection(properties.getProperty("speed_shield_pswd_collection").trim().toString());
		thirdProperties.setSpeed_shield_url_collection(properties.getProperty("speed_shield_url_collection").trim().toString());
		thirdProperties.setSpeed_shield_userId(properties.getProperty("speed_shield_userId").trim().toString());
		thirdProperties.setShzx_certificate_url(properties.getProperty("shzx_certificate_url").trim().toString());
		thirdProperties.setCl_marketing_accout(properties.getProperty("cl_marketing_accout").trim().toString());
		thirdProperties.setCl_marketing_password(properties.getProperty("cl_marketing_password").trim().toString());
		thirdProperties.setCl_request_url(properties.getProperty("cl_request_url").trim().toString());
		thirdProperties.setCl_cl_verify_code_password(properties.getProperty("cl_verify_code_password").trim().toString());
		thirdProperties.setCl_verify_code_accout(properties.getProperty("cl_verify_code_accout").trim().toString());
		thirdProperties.setCl_sign_name(properties.getProperty("cl_sign_name").trim().toString());
		thirdProperties.setMw_market_pwd(properties.getProperty("mw_market_pwd").trim().toString());
		thirdProperties.setMw_market_userId(properties.getProperty("mw_market_userId").trim().toString());
		thirdProperties.setMw_message_pwd(properties.getProperty("mw_message_pwd").trim().toString());
		thirdProperties.setMw_message_userId(properties.getProperty("mw_message_userId").trim().toString());
		thirdProperties.setMw_request_url(properties.getProperty("mw_request_url").trim().toString());
		thirdProperties.setOpen_view_api_key(properties.getProperty("open_view_api_key").trim().toString());
		thirdProperties.setOpen_view_api_secret(properties.getProperty("open_view_api_secret").trim().toString());
		thirdProperties.setOpen_view_bank_card_request_url(properties.getProperty("open_view_bank_card_request_url").trim().toString());
		thirdProperties.setOpen_view_face_ocr_request_url(properties.getProperty("open_view_face_ocr_request_url").trim().toString());
		thirdProperties.setOpen_view_id_card_request_url(properties.getProperty("open_view_id_card_request_url").trim().toString());
		thirdProperties.setMx_baseUrl_new(properties.getProperty("mx_baseUrl_new").trim().toString());
		thirdProperties.setBr_xss_interface_product_code(properties.getProperty("br_xss_interface_product_code").trim().toString());
		thirdProperties.setBr_other_interface_product_code(properties.getProperty("br_other_interface_product_code").trim().toString());
		
		thirdProperties.setShzx_url_prefix(properties.getProperty("shzx_url_prefix").trim().toString());
		thirdProperties.setShzx_batchcreditwebservice_uri(properties.getProperty("shzx_batchcreditwebservice_uri").trim().toString());
		thirdProperties.setShzx_user_name(properties.getProperty("shzx_user_name").trim().toString());
		thirdProperties.setShzx_pass_word(properties.getProperty("shzx_pass_word").trim().toString());
		thirdProperties.setShzx_org_code(properties.getProperty("shzx_org_code").trim().toString());
		thirdProperties.setShzx_sse_cret(properties.getProperty("shzx_sse_cret").trim().toString());
		thirdProperties.setShzx_zippass_word(properties.getProperty("shzx_zippass_word").trim().toString());
		thirdProperties.setShzx_step1_url(properties.getProperty("shzx_step1_url").trim().toString());
		thirdProperties.setShzx_step2_url(properties.getProperty("shzx_step2_url").trim().toString());
		thirdProperties.setShzx_url_prefix(properties.getProperty("shzx_url_prefix").trim().toString());
		thirdProperties.setShzx_switch(properties.getProperty("shzx_switch").trim().toString());
		thirdProperties.setFast_pay_withhold_merchantId(properties.getProperty("fast_pay_withhold_merchantId").trim().toString());
		thirdProperties.setFast_withhold_deducted_agreement(properties.getProperty("fast_withhold_deducted_agreement").trim().toString());
		thirdProperties.setFast_withhold_query_account_amount_product_no(properties.getProperty("fast_withhold_query_account_amount_product_no").trim().toString());
		thirdProperties.setFast_withhold_query_transaction_results(properties.getProperty("fast_withhold_query_transaction_results").trim().toString());
		thirdProperties.setBj_fh_request_url(properties.getProperty("bj_fh_request_url").trim().toString());
		thirdProperties.setBj_fh_account_yx(properties.getProperty("bj_fh_account_yx").trim().toString());
		thirdProperties.setBj_fh_password_yx(properties.getProperty("bj_fh_password_yx").trim().toString());
		thirdProperties.setBj_fh_account_hy(properties.getProperty("bj_fh_account_hy").trim().toString());
		thirdProperties.setBj_fh_password_hy(properties.getProperty("bj_fh_password_hy").trim().toString());
		thirdProperties.setBj_fh_sign_name(properties.getProperty("bj_fh_sign_name").trim().toString());
		thirdProperties.setBj_fh_sign_name(properties.getProperty("bj_fh_sign_name").trim().toString());
		thirdProperties.setEnterpriseMsg_account_hy(properties.getProperty("enterpriseMsg_account_hy").trim().toString());
		thirdProperties.setEnterpriseMsg_account_yx(properties.getProperty("enterpriseMsg_account_yx").trim().toString());
		thirdProperties.setEnterpriseMsg_password_hy(properties.getProperty("enterpriseMsg_password_hy").trim().toString());
		thirdProperties.setEnterpriseMsg_password_yx(properties.getProperty("enterpriseMsg_password_yx").trim().toString());
		thirdProperties.setEnterpriseMsg_requestUrl(properties.getProperty("enterpriseMsg_requestUrl").trim().toString());
		thirdProperties.setEnterpriseMsg_sign_name(properties.getProperty("enterpriseMsg_sign_name").trim().toString());
		thirdProperties.setEnterpriseMsg_userid_hy(properties.getProperty("enterpriseMsg_userid_hy").trim().toString());
		thirdProperties.setEnterpriseMsg_userid_yx(properties.getProperty("enterpriseMsg_userid_yx").trim().toString());
		thirdProperties.setBr_whiteList_apiCode(properties.getProperty("br_whiteList_apiCode").trim().toString());
		thirdProperties.setBr_whiteList_company_num(properties.getProperty("br_whiteList_company_num").trim().toString());
		thirdProperties.setBr_whiteList_merchantName(properties.getProperty("br_whiteList_merchantName").trim().toString());
		thirdProperties.setBr_whiteList_merchantPwd(properties.getProperty("br_whiteList_merchantPwd").trim().toString());
		thirdProperties.setBr_whiteList_request_url(properties.getProperty("br_whiteList_request_url").trim().toString());
		thirdProperties.setBr_scorelargecashv2_open(properties.getProperty("br_scorelargecashv2_open").trim().toString());
		thirdProperties.setOpen_view_get_random_number(properties.getProperty("open_view_get_random_number").trim().toString());
		thirdProperties.setOpen_view_validate_video(properties.getProperty("open_view_validate_video").trim().toString());
		thirdProperties.setOpen_view_verify(properties.getProperty("open_view_verify").trim().toString());
		thirdProperties.setFace_fail_frequency(properties.getProperty("face_fail_frequency").trim().toString());
		thirdProperties.setFace_fail_frequency2(properties.getProperty("face_fail_frequency2").trim().toString());
		return thirdProperties;
	}
}
